import http from '../util/http.js';

const API={
    get:(url)=>{return http({url:url,method:'get'})},
    del:(url,id)=>{
        //url /api/staff
        //id  12
        //url = /api/staff/12
        //url = http://localhost:8080/staff/12
        url = url + '/' + id;
        return http({url:url,method:'delete'})
    },
    postForm:function(url,params){
        return http({url:url,method:'post', params: params})
    },
    postJson:function(url,data){
        return http({url:url,method:'post',data:data})
    },
    putForm:function(url,params){
        return http({url:url,method:'put', params: params})
    },
    putJson:function(url,data){
        return http({url:url,method:'put',data:data})
    },
    getSearch:(url,params)=>{
        return http({url:url,method:'get',params:params})
    },
    delJson:(url,data)=>{
        return http({url:url,method:'delete',data:data})
    },
    getByID:(url,id)=>{
        //url /api/staff
        //id  12
        //url = /api/staff/12
        //url = http://localhost:8080/staff/12
        url = url + '/' + id;
        return http({url:url,method:'get'})
    },
};

export default API;